package com.honey.mybatis.generator.criteria.method;

import com.honey.compilation.java.Clazz;
import com.honey.compilation.java.JavaKeyWord;
import com.honey.compilation.java.JavaVisibility;
import com.honey.compilation.java.MethodDecoration;
import com.honey.compilation.java.Parameter;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.core.types.JDKFullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractMethod;
import com.honey.mybatis.generator.MybatisPlugin;
import com.honey.mybatis.generator.criteria.CriteriaConstant;

public class Criterion3Method extends AbstractMethod {
	
	private static final Parameter[] PARAMETER = new Parameter[]{
		//new Parameter(JDKFullyQualifiedJavaType.getStringInstance(),CriteriaConstant.CONDITION_FIELD_NAME),
		new Parameter(new FullyQualifiedJavaType("Enum<?>"),"name"),
		new Parameter(new FullyQualifiedJavaType(CriteriaConstant.TERM_CLASS_NAME),CriteriaConstant.TERM_FIELD_NAME),
		new Parameter(JDKFullyQualifiedJavaType.getObjectInstance(),"value"),
	} ;
	
	private static final String[] BODY = new String[]{
		JavaKeyWord.THIS+"(name, "+CriteriaConstant.TERM_FIELD_NAME+", value, null)"
	};
	
	public Criterion3Method(){
	}
	public Criterion3Method(Clazz clazz, MybatisPlugin belongPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(clazz, belongPlugin, introspectSchema, introspectSchemaColumn);
	}
		
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getMethodName()
	 */
	@Override
	protected String getMethodName() {
		return CriteriaConstant.CRITERION_CLASS_NAME;
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getMethodDecoration()
	 */
	protected MethodDecoration getMethodDecoration() {
		MethodDecoration methodDecoration =  super.getMethodDecoration();
		methodDecoration.setConstructor(true);
		methodDecoration.setVisibility(JavaVisibility.PROTECTED);
		return methodDecoration;
	}
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getBody()
	 */
	@Override
	protected String[] getBody() {
		
		return BODY;
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractMethod#getParameter()
	 */
	@Override
	protected Parameter[] getParameter() {
		return PARAMETER;
	}
	
	
	public static void main(String []args){
		Criterion3Method  cm = new Criterion3Method();
		System.out.println(cm.createMethod().compiledContent(0)); 
	}
}
